home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000145_icon-group-sender _Wed Jun 23 09:06:42 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  1KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id JAA10826
  4.     for icon-group-addresses; Wed, 23 Jun 1999 09:06:30 -0700 (MST)
  5. Message-Id: <199906231606.JAA10826@baskerville.CS.Arizona.EDU>
  6. To: icon-group@optima.CS.Arizona.EDU
  7. Date: 23 Jun 1999 10:17:28 GMT
  8. From: eddie@holyrood.ed.ac.uk (Eddie Corns)
  9. Subject: Re: Assertions in Icon
  10. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  11. Status: RO
  12.  
  13. Kostas Oikonomou <oikonomou@att.com> writes:
  14.  
  15.  
  16. >Hello,
  17.  
  18. >Does anyone have a suggestion about how to implement a procedure "assert",
  19. >which, when called with an expression "e" as argument, implements
  20.  
  21. >        e | stop("Assertion on line ", &line, " failed!")
  22.  
  23. >Here &line should be the line on which assert(e) appears.
  24. >Thanks.
  25.  
  26. >                Kostas Oikonomou
  27.  
  28. Easiest soln which occurs to me is to use a preprocessor to convert
  29.  
  30.     assert(e)
  31.  
  32. to the form you want.  Either inline it or replace with do_assert(e,nnn) where
  33. nnn is the line no.
  34.  
  35. I usually use symobolic tags like
  36.  
  37.     assert(e,"RDF4")
  38.  
  39. then use a file that maps tags to meaningful messages like "Read failed in
  40. Open Directory".  (Well to be truthful, most of the time I just print the tag
  41. and check it in the source).
  42.  
  43. Eddie
  44.